package com.fenxiangle.yueding.feature.extension.model;

import com.fenxiangle.yueding.common.httprequestbody.HttpRequestBody;
import com.fenxiangle.yueding.entity.bo.AliPayBo;
import com.fenxiangle.yueding.entity.bo.ExtensionBo;
import com.fenxiangle.yueding.feature.extension.contract.ExtensionContract;
import com.fenxiangle.yueding.feature.extension.login.DaggerExtensionModelComponent;
import com.fenxiangle.yueding.framework.api.ApiLib;
import com.fenxiangle.yueding.framework.api.UserApi;
import com.suozhang.framework.component.http.RxDataProcessFactory;

import org.json.JSONObject;

import javax.inject.Inject;

import io.reactivex.Observable;
import okhttp3.RequestBody;

public class ExtensionModel implements ExtensionContract.Model{
    @Inject
    UserApi api;


    @Inject
    public ExtensionModel() {
        DaggerExtensionModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<ExtensionBo> user_Extension_Center() {
        return api.user_Extension_Center().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<AliPayBo> recharge_member(JSONObject jsonObject) {
        RequestBody body = HttpRequestBody.getRequestBody(jsonObject);
        return api.recharge_member(body).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<AliPayBo> user_forward(JSONObject jsonObject) {
        RequestBody body = HttpRequestBody.getRequestBody(jsonObject);
        return api.user_forward(body).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> is_set_pwd() {
        return api.is_set_pwd().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> user_payment_set(JSONObject jsonObject) {
        RequestBody body = HttpRequestBody.getRequestBody(jsonObject);
        return api.user_payment_set(body).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
